package org.odata4j.examples.producer.jpa.contacts;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;


/**
 * A JPA annotated @Embeddable class that models an {@link Address}.
 */
@Embeddable
public class Address implements Serializable {
  private static final long serialVersionUID = 1L;

  @Column(name = "Address")
  private String Address;
  @Column(name = "City")
  private String City;
  @Column(name = "Region")
  private Integer Region;
  @Column(name = "PostalCode")
  private Integer PostalCode;
  @Column(name = "Country")
  private String Country;
  @Embedded
  private AuditLog AuditLog;

  public Address() {}

  public String getAddress() {
    return Address;
  }

  public void setAddress(String address) {
    Address = address;
  }

  public String getCity() {
    return City;
  }

  public void setCity(String city) {
    City = city;
  }

  public Integer getRegion() {
    return Region;
  }

  public void setRegion(Integer region) {
    Region = region;
  }

  public Integer getPostalCode() {
    return PostalCode;
  }

  public void setPostalCode(Integer postalCode) {
    PostalCode = postalCode;
  }

  public String getCountry() {
    return Country;
  }

  public void setCountry(String country) {
    Country = country;
  }

  public AuditLog getAuditLog() {
    return AuditLog;
  }
  
  public void setAuditLog(AuditLog auditLog) {
    AuditLog = auditLog;
  }
  
  @Override
  public int hashCode() {
    int hash = 0;
    hash += (Address != null ? Address.hashCode() : 0);
    hash += (City != null ? City.hashCode() : 0);
    hash += (Region != null ? Region.hashCode() : 0);
    hash += (PostalCode != null ? PostalCode.hashCode() : 0);
    hash += (Country != null ? Country.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    if (!(object instanceof Address)) {
      return false;
    }
    Address other = (Address) object;
    
    if ((Address == null && other.Address != null)
        || (Address != null && !Address.equals(other.Address))) {
      return false;
    }
    if ((City == null && other.City != null)
        || (City != null && !City.equals(other.City))) {
      return false;
    }
    if ((Region == null && other.Region != null)
        || (Region != null && !Region.equals(other.Region))) {
      return false;
    }
    if ((PostalCode == null && other.PostalCode != null)
        || (PostalCode != null && !PostalCode.equals(other.PostalCode))) {
      return false;
    }
    if ((Country == null && other.Country != null)
        || (Country != null && !Country.equals(other.Country))) {
      return false;
    }
    
    return true;
  }

  @Override
  public String toString() {
    return "org.odata4j.examples.producer.jpa.northwind.Address[address=" + Address 
        + ", city=" + City + ", region=" + Region + ", postalCode=" + PostalCode + ", country=" + Country + "]";
  }

}
